package com.bole.controller;


import com.bole.data.Result;
import com.bole.data.ResultEnum;
import com.bole.dto.brand.DicBrandDto;
import com.bole.feign.DicBrandFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("brand")
@Api(value = "品牌管理接口")
public class BrandController {

    @Autowired
    private DicBrandFeign brandFeign;


    @GetMapping("getBrandInfo")
    @ApiOperation(value = "查询品牌信息",notes = "查询品牌信息")
    @ResponseBody
    public Result getBrandInfo(){
        List<DicBrandDto> brandInfo = brandFeign.getBrandInfo();
        return Result.response(ResultEnum.OK).setData(brandInfo);
    }

    //通过first_char查询
    @GetMapping("getFirstChar")
    @ApiOperation(value = "通过fitstChar查询",notes = "通过fitstChaar查询")
    @ApiImplicitParam(name = "firstChar", value = "首字母", required = true, dataTypeClass = String.class)
    @ResponseBody
    public Result getFirstChar(@RequestParam String firstChar){
        List<DicBrandDto> brandInfo = brandFeign.getBrandFirstChar(firstChar);
        return Result.response(ResultEnum.OK).setData(brandInfo);
    }

}
